package org.spring.learn.demo.annotation.configures.imports;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Arrays;

public class MyTest {

    @Test
    public void test(){

        ApplicationContext app = new AnnotationConfigApplicationContext(MyConfig.class);

        String[] beanNames = app.getBeanDefinitionNames();
        System.out.println("============"+app.getBean("monkey").getClass());

        Object monkey1 = app.getBean("monkey");
        Object monkey2 = app.getBean("monkey");

        Object monkeyFactoryBean = app.getBean("&monkey");
        System.out.println(monkeyFactoryBean);
        System.out.println(monkey1==monkey2);
        System.out.println(Arrays.toString(beanNames)
                .replaceAll("\\[|\\]", "")
                .replaceAll(",", "\n")
        );
    }
}
